<!DOCTYPE HTML>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8">
    <title>Powerful JQuery Plugins</title>
    <link href="/js/jQueryUI/jquery-ui.css" type="text/css" rel="stylesheet"></link>
    <link href="/js/jQueryScrollbar/perfect-scrollbar.css" type="text/css" rel="stylesheet"></link>
  </head>
  
  <body>
    <div>使用Object Literal 封装匿名函数</div>
    <script src="/js/jQuery/jquery-1.11.3.js" type="text/javascript"></script>
    <script src="/js/jQueryUI/jquery-ui.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/jquery.validate.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/messages_zh.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/additional-methods.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/additional-methods.js" type="text/javascript"></script>
    <script src="/js/jQueryScrollbar/perfect-scrollbar.jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            console.info("小心匿名函数");
            //到处绑定匿名函数是一个灾难。它们很难被调试、维护、测试和重用
            //使用对象文字去阻止和命名你的处理器和回调函数
            $("1body").click(function() {
            	$("<div></div>")
            	   .html("传统的书写形式，通过绑定匿名函数，这样做是不好的！")
            	   .appendTo("body")
            	   .fadeOut()
            	   .fadeIn();
            });
            
            var body = {
            	onReady: function() {
            		$("body").click(body);
            	},
            	show: function(event) {
                    $("<div></div>")
                    .html("传统的书写形式，通过绑定匿名函数，这样做是不好的！")
                    .appendTo("body")
                    .fadeOut()
                    .fadeIn();
            	}
            };
            body.onReady();
        });
    </script>
  </body>
</html>